package common;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.lang.Console;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import org.apache.commons.lang3.builder.ToStringExclude;
import org.junit.jupiter.api.Test;

/**
 * @author 马泽朋
 * @version 1.0
 * @date 2019/10/20 10:43
 */
public class Teathu {
    @Test
    public void test01(){
        byte[] data = "我是一段测试字符串".getBytes();
        Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);

//签名
        byte[] signed = sign.sign("我是段测试字符串".getBytes());
        System.out.println(signed);
//验证签名
        boolean verify = sign.verify(data, signed);
        System.out.println(verify);
    }
    @Test
    public void test02(){
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);

        //图形验证码写出，可以写出到文件，也可以写出到流
        //lineCaptcha.write("d:/");
        //输出code
        Console.log(lineCaptcha.getCode());
        System.out.println(lineCaptcha.getCode());
        //验证图形验证码的有效性，返回boolean值
        lineCaptcha.verify("1234");
    }
}
